#include <fstream>
#include <iostream>
#include <boost/iostreams/device/file.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#include <sstream>

using namespace std;

int main() 
{
    stringstream ss;
    ss << "1234567";
    if(true)
    {
        // output to gzip
        boost::iostreams::filtering_ostream out;
        out.push(boost::iostreams::gzip_compressor());
        out.push(boost::iostreams::file_sink("data.gz"));
        out << "123456789\n";
        for(int i = 1; i <= 100; ++ i)
            out << "1289234" << "\n";
        boost::iostreams::close(out);
    }
    else
    {
        // output to cout
        cout << ss.str();
    }
}
